package com.yingside.io.io;

import java.io.*;
import java.nio.Buffer;

public class TestBufferedInputStream {
    public static void main(String[] args) {
        FileInputStream fis = null;
        FileOutputStream fos = null;
        BufferedInputStream bis = null;
        BufferedOutputStream bos = null;
        try {
            fis = new FileInputStream("/Users/yingside/Desktop/美女.jpg");
            fos = new FileOutputStream("images/漂亮妹妹.jpg");
            bis = new BufferedInputStream(new BufferedInputStream(fis));
            bos = new BufferedOutputStream(fos);

            byte [] bs = new byte[1024];
            int n = -1;

            while((n = bis.read(bs)) != -1){
                bos.write(bs,0,n);
            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                bis.close();
            } catch (IOException e) {
                e.printStackTrace();
            }

            try {
                bos.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
